local bozhenhu = fk.CreateSkill({
    name = "bozhenhu",
})

Fk:loadTranslationTable{
    ["bozhenhu"] = "震虎",
    [":bozhenhu"] = "出牌阶段限一次，你可以与一名体力值大于或等于你的角色拼点：若你赢，加1点体力上限并回复1点体力；若你没赢，其对你造成1点伤害。",
    ["#bozhenhu"] = "震虎：选择一名体力值大于或等于且有手牌的角色拼点",
    ["#bozhenhu-heal"] = "震虎：回复1点体力",
    ["$bozhenhu1"] = "君同日月，国若山河，吾不敢舍昼夜。",
    ["$bozhenhu2"] = "人生百载，或死利，或死欲，死义可乎？",
}

bozhenhu:addEffect("active", {
    anim_type = "pindian",
    prompt = "#bozhenhu",
    max_phase_use_time = 1,
    card_num = 0,
    target_num = 1,
    can_use = function(self, player)
        return not player:isKongcheng() and 
               player:usedSkillTimes(bozhenhu.name, Player.HistoryPhase) == 0
    end,
    target_filter = function(self, player, to_select, selected)
        -- 目标必须有手牌且体力值≥自己
        return #selected == 0 and to_select.hp >= player.hp and not to_select:isKongcheng()
    end,
    on_use = function(self, room, effect)
        local player = effect.from
        local target = effect.tos[1]
        
        -- 目标空牌时直接返回
        if target:isKongcheng() then
            
            return
        end
        
        local pindian = player:pindian({target}, bozhenhu.name)
        if player.dead or target.dead then return end
        
        local result = pindian.results[target]
        if result.winner == player then
            -- 拼点获胜，增加体力上限
            if player.maxHp < 8 then
                room:changeMaxHp(player, 1)
                
                -- 增加体力上限后恢复1点体力
                if player.hp < player.maxHp then
                    room:recover{
                        who = player,
                        num = 1,
                        skillName = bozhenhu.name,
                    }
                end
            end
        else
            -- 拼点失败，受到伤害
            room:damage{
                from = target,
                to = player,
                damage = 1,
                skillName = bozhenhu.name,
            }
        end
    end,
})

return bozhenhu
